package com.resource.controller;

import com.resource.dto.OfficeProjectInfoDto;
import com.resource.query.ProjectQuery;
import com.resource.service.OfficeProjectService;
import com.resource.service.OfficeTokenService;
import com.sijibao.open.api.common.BaseClient;
import com.sijibao.open.api.common.BaseRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.security.Principal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

/**
 * 测试资源服务器
 *
 * @author Tao.yu
 * @version v3.0
 * @date 2020/9/14 14:02
 **/
@RestController
@RequestMapping("/api")
public class MemberController {
	@Resource
	private OfficeTokenService officeTokenService;
	@Resource
	private OfficeProjectService officeProjectService;
	@GetMapping("/member")
	public Principal user(Principal member) {
		return member;
	}

//	@GetMapping("/getToken")
//	public String getToken(){
//		return officeTokenService.getToken();
//	}
//	@GetMapping("/getProjectInfo")
//	public String getProjectInfo(){
//		officeProjectService.getProjectInfoById(1);
//		return "success";
//	}

//	@GetMapping("/getProjectList")
//	public List<OfficeProjectInfoDto> getProjectList(){
//		ProjectQuery projectQuery=new ProjectQuery();
//		return officeProjectService.getProjectList(projectQuery);
//	}

//	@PostMapping("/addProject")
//	public String addProject(@RequestBody OfficeProjectInfoDto dto){
//		officeProjectService.addProject(dto);
//		return "success";
//	}
//
//	@DeleteMapping("/removeProject/{managerId}")
//	public String addProject(@PathVariable("managerId") String managerId ){
//		officeProjectService.removeProject(managerId);
//		return "success";
//	}
//
//	@PutMapping("/modifyProject/{managerId}")
//	public String modifyProject(@PathVariable("managerId") Integer managerId ){
//		OfficeProjectInfoDto dto=new OfficeProjectInfoDto();
//		dto.setUserId("admin");
//		dto.setManagerId(managerId);
//		dto.setManagerName("大熊的测试项目"+ System.currentTimeMillis());
//		officeProjectService.modifyProject(dto);
//		return "success";
//	}


	public static void main(String[] args) {
		String gatewayUrl = "https://api.sijibao.com";
		String ak = "12024C2FAC57479A86805B2B1F875196";
		String sk = "3B3E8EB96846419C93EABC627DC653B2";
		String path = "/open/ucenter-platform/queryCompanyForOa";
		Map<String,Object> map = new HashMap<>();
		//map.put("companyName", "测试");
		//map.put("companyAdminCode","200000009633");
		map.put("pageNum","1");
		map.put("pageSize","20");
		BaseRequest baseRequest = new BaseRequest(path,gatewayUrl,map,ak,sk);
		try {
			String send = BaseClient.send(baseRequest);
			System.out.println(send);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
